home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d15
/
fntfig.arc
/
VECTOR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-10-11
|
5KB
|
149 lines
/*------------------------------
VECTOR.C -- Vector Font Demo
------------------------------*/
#define INCL_WIN
#define INCL_GPI
#include <os2.h>
#include <string.h>
#include "text.h"
#include "easyfont.h"
#define LCID_RASTFONT 1L
#define LCID_VECTFONT 2L
MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
HAB hab ;
int main (void)
{
static CHAR szClientClass [] = "Vector" ;
static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
FCF_SIZEBORDER | FCF_MINMAX |
FCF_SHELLPOSITION | FCF_TASKLIST ;
HMQ hmq ;
HWND hwndFrame, hwndClient ;
QMSG qmsg ;
hab = WinInitialize (0) ;
hmq = WinCreateMsgQueue (hab, 0) ;
WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
&flFrameFlags, szClientClass, NULL,
0L, NULL, 0, &hwndClient) ;
WinSendMsg (hwndFrame, WM_SETICON,
WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE),
NULL) ;
while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
WinDispatchMsg (hab, &qmsg) ;
WinDestroyWindow (hwndFrame) ;
WinDestroyMsgQueue (hmq) ;
WinTerminate (hab) ;
return 0 ;
}
MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
static HPS hps ;
static SHORT sNumLines = sizeof aszText / sizeof aszText[0] ;
static SIZEL sizlClient ;
FATTRS fat ;
FONTMETRICS fmRast, fmVect ;
HDC hdc ;
POINTL ptl ;
SHORT i ;
SIZEF sizfxBox ;
SIZEL sizlBox, sizlPage ;
switch (msg)
{
case WM_CREATE:
hdc = WinOpenWindowDC (hwnd) ;
sizlPage.cx = 0 ;
sizlPage.cy = 0 ;
hps = GpiCreatePS (hab, hdc, &sizlPage,
PU_PELS | GPIF_DEFAULT |
GPIT_MICRO | GPIA_ASSOC) ;
EzfQueryFonts (hps) ;
return 0 ;
case WM_SIZE:
sizlClient.cx = SHORT1FROMMP (mp2) ;
sizlClient.cy = SHORT2FROMMP (mp2) ;
return 0 ;
case WM_PAINT:
WinBeginPaint (hwnd, hps, NULL) ;
GpiErase (hps) ;
// Raster Font
EzfCreateLogFont (hps, LCID_RASTFONT, FONTFACE_TIMES,
FONTSIZE_10, 0) ;
GpiSetCharSet (hps, LCID_RASTFONT) ;
GpiQueryFontMetrics (hps, (LONG) sizeof fmRast, &fmRast) ;
GpiSetCharSet (hps, LCID_DEFAULT) ;
GpiDeleteSetId (hps, LCID_RASTFONT) ;
// Vector Font
fat.usRecordLength = sizeof (fat) ;
fat.fsSelection = 0 ;
fat.lMatch = 0 ;
fat.idRegistry = 0 ;
fat.usCodePage = GpiQueryCp (hps) ;
fat.lMaxBaselineExt = 0 ;
fat.lAveCharWidth = 0 ;
fat.fsType = 0 ;
fat.fsFontUse = FATTR_FONTUSE_OUTLINE ;
strcpy (fat.szFacename, "Tms Rmn") ;
GpiCreateLogFont (hps, NULL, LCID_VECTFONT, &fat) ;
GpiSetCharSet (hps, LCID_VECTFONT) ;
GpiQueryDefCharBox (hps, &sizlBox) ;
sizfxBox.cx = MAKEFIXED (sizlBox.cx, 0) ;
sizfxBox.cy = MAKEFIXED (sizlBox.cy, 0) ;
GpiSetCharBox (hps, &sizfxBox) ;
GpiQueryFontMetrics (hps, (LONG) sizeof fmVect, &fmVect) ;
sizfxBox.cx = fmRast.lAveCharWidth * sizfxBox.cx / fmVect.lAveCharWidth ;
sizfxBox.cy = fmRast.lMaxBaselineExt * sizfxBox.cy / fmVect.lMaxBaselineExt ;
GpiSetCharBox (hps, &sizfxBox) ;
GpiQueryFontMetrics (hps, (LONG) sizeof fmVect, &fmVect) ;
ptl.x = fmVect.lAveCharWidth ;
ptl.y = sizlClient.cy - fmVect.lMaxBaselineExt + fmVect.lMaxDescender ;
for (i = 0 ; i < sNumLines ; i++)
{
GpiCharStringAt (hps, &ptl, (LONG) strlen (aszText[i]),
aszText[i]) ;
ptl.y -= fmVect.lMaxBaselineExt ;
}
GpiSetCharSet (hps, LCID_DEFAULT) ;
GpiDeleteSetId (hps, LCID_VECTFONT) ;
WinEndPaint (hps) ;
return 0 ;
case WM_DESTROY:
GpiDestroyPS (hps) ;
return 0 ;
}
return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
}